//
//  ResetPasswdStepTwoViewController.swift
//  cxd4iphone
//
//  Created by hexy on 12/9/15.
//  Copyright © 2015 hexy. All rights reserved.
//

import UIKit

private struct kConstraints {
    
    static let headerHeight: CGFloat = xx_height(200)
    static let headerRect: CGRect    = CGRectMake(0, 0, xx_screenWidth(), kConstraints.headerHeight)
}

class ResetPasswdViewController: BaseTableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let header =  ResetPasswdView(frame: kConstraints.headerRect)
        
        xx_showMaskHUD(nil)
        header.sureBtn.rac_signalForControlEvents(.TouchUpInside).subscribeNext { (_) -> Void in
            
            AccountViewModel.shared.resetLoginPwd(header.newPasswdTextField.text!).subscribeError({ (error) -> Void in
                
                xx_print(error)
                    xx_showError(error)
                
                }, completed: { () -> Void in
                    
                    xx_hideHUD()
                    
                    AppDelegate.selectMeViewController()
                    self.dismissViewControllerAnimated(true, completion: {
                        LoginViewController.show()
                    })
            })
        }
        tableView.tableHeaderView = header

    }

    

}
